//
//  ANTextView.m
//  Ants
//
//  Created by ZHM on 16/5/17.
//  Copyright © 2016年 ZHM. All rights reserved.
//

#import "ANTextView.h"

@interface ANTextView ()

@property (nonatomic, weak) UILabel *placeHolderLabel;

@end

@implementation ANTextView

- (UILabel *)placeHolderLabel {
    if (!_placeHolderLabel) {
        UILabel *label = [[UILabel alloc] init];
        label.alpha = 0.3;
        [self addSubview:label];
        _placeHolderLabel = label;
    }
    return _placeHolderLabel;
}

- (void)setHiddenPlaceHolder:(BOOL)hiddenPlaceHolder {
    _hiddenPlaceHolder = hiddenPlaceHolder;
    _placeHolderLabel.hidden = hiddenPlaceHolder;
}


- (void)setPlaceHolder:(NSString *)placeHolder {
    _placeHolder = placeHolder;
    self.placeHolderLabel.text = placeHolder;
    //大小跟文字一样
    [self.placeHolderLabel sizeToFit];
}

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.font = [UIFont systemFontOfSize:13.0];
    }
    return self;
}

- (void)setFont:(UIFont *)font {
    [super setFont:font];
    self.placeHolderLabel.font = font;
    [self.placeHolderLabel sizeToFit];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    //调整x.y对齐
    self.placeHolderLabel.x = 5;
    self.placeHolderLabel.y = 8;
}


@end
